<?php
/**
 * User: zyj
 * Date: 2019/11/4
 */
namespace app\manage\logic;

use app\manage\model\AuthRule;
use think\Db;

class System extends Base
{
    /**
     * 插入菜单
     * @param array $data
     * @author zyj<535985755@qq.com>
     * Date: 2019/11/4
     */
    public function addMenu(array $data)
    {
        $info = AuthRule::create($data);
        return $info;
    }

    /**
     * @param array $data
     * @return array|bool
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     * @author zyj<535985755@qq.com>
     * Date: 2019/11/7
     */
    public function editMenu(array $data)
    {
        $menuData = AuthRule::where("id","=",$data['id'])->select();
        if($menuData){
            $map['id'] = $data['id'];
            $info = AuthRule::where($map)->save($data);
        }
        return $info ?? [];
    }

    /**
     * @return \think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     * @author zyj<535985755@qq.com>
     * Date: 2019/11/7
     */
    public function getMenu()
    {
        $menuData = AuthRule::where("status","=","=")->select();
        return $menuData;
    }

}